package com.autism;

import com.autism.inherit.*;

public class Main {

    public static void main(String[] args) {
        Point p = new Point(2, 3);
        Point p2 = new Point(4, 6);
        System.out.println(p.toString());
        System.out.println(p.distance(p2));

        Point center = new Point(2, 3);
        //创建圆，赋值给circle
        Circle circle = new Circle(center, 2);
        circle.setColor("pink");
        //调用draw方法，会执行Circle的draw方法
        circle.draw();
        //输出圆面积
        System.out.println(circle.area());

        ShapeManager manager = new ShapeManager();

        manager.addShape(new Circle(new Point(4, 4), 3));
        manager.addShape(new Line(new Point(2, 3),
                new Point(3, 4), "green"));
        manager.addShape(new ArrowLine(new Point(1, 2),
                new Point(5, 5), "black", false, true));

        manager.draw();

        //在new的过程中，首先初始化父类，在父类的构造方法中调用了test（）方法，因为test（）方法在子类中被重写，所以会调用子类的test（）方法。
        //子类的test（）方法访问了子类的实例变量number，而此时子类的实例变量赋值语句和构造方法还没有执行，所以输出默认值0
        Child child = new Child();
        child.test();
    }
}
